<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>360考试认证平台</title>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
</head>

<body>

<!-- Guacamole -->
<script type="text/javascript"
        src="../static/guacamole-common-js/all.min.js"></script>
<!-- Display -->
<div id="display" style="cursor: none"></div>

<!-- Init -->
<script th:inline="javascript"> /* <![CDATA[ */
var http_tunnel = [[${base_url}]];
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.

var guac = new Guacamole.Client(
    new Guacamole.HTTPTunnel(http_tunnel)
);

// Add client to display div
display.appendChild(guac.getDisplay().getElement());

// Error handler
guac.onerror = function (error) {
    if (error.code === 519) {
        alert("连接失败,请联系管理员");
    }
    else if (error.code === 521)
        alert("此主机已从其他终端登录");
    else
        alert("连接失败,请联系管理员");

};

// Connect
guac.connect();

// Disconnect on close
window.onunload = function () {
    guac.disconnect();
}

/* ]]> */ </script>


<script type="text/javascript"> /* <![CDATA[ */

// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());

mouse.onmousedown =
    mouse.onmouseup =
        mouse.onmousemove = function (mouseState) {
            guac.sendMouseState(mouseState);
        };


// Keyboard
var keyboard = new Guacamole.Keyboard(document);

keyboard.onkeydown = function (keysym) {
    guac.sendKeyEvent(1, keysym);
};

keyboard.onkeyup = function (keysym) {
    guac.sendKeyEvent(0, keysym);
};

/* ]]> */ </script>

<script type="text/javascript">
    //提取到函数外面作为全局变量
    var rm = document.getElementById("display");

    //自定义一个浏览器右键菜单，单击右键是显示它
    //oncontextmenu上下文菜单事件，右键菜单
    rm.oncontextmenu = function (e) {

        //阻止默认的右键菜单显示
        return false;
    };

</script>
</body>


</html>